<template>
  <div></div>
</template>

<script setup name="wxpage">
import { ref, reactive, onMounted, computed } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { storeToRefs } from 'pinia';
import { Session } from '/@/utils/storage';
import { useProConfig } from '/@/stores/proConfig';

const router = useRouter();
const proConfig= useProConfig();
const { config } = storeToRefs(proConfig);
const {wxappid, wxredirect_uri, wxagentid} = config.value;

const wxpage = computed(() => {
  let url = 'https://open.weixin.qq.com/connect/oauth2/authorize?'
  url += 'appid=' + wxappid
  url += '&redirect_uri=' + encodeURIComponent(wxredirect_uri)
  url += '&response_type=code&scope=snsapi_privateinfo&state=STATE'
  url += "&agentid=" + wxagentid + "#wechat_redirect"
  return url;
});
const nextPage = ()=>{
  const token = Session.get('token');
  if(token){
    router.push("/")
  }else{
    window.location.href = wxpage.value
  }
}
onMounted(()=>{
  nextPage();
})
</script>

<style scoped>

</style>
